package in.co.codedoc.sql;

import org.junit.Test;

import in.co.codedoc.tests.JUNitTestBase;

//Clearly these queries make no business sense. Just there to test syntax of generated queries.
public class SQLTests
	extends JUNitTestBase
{
	@Test
	public void FunctionTest()
	{
		SubqueryStatement subquery 
			= new SubqueryStatement(new TransformedTableColumn("bar",new TransformedTableColumn("foo",TestTableColumns.Id)));
		
		
		TestTable.Find
		(
			new WhereClause()
			.And(TestTableColumns.Id,WhereClause.Op.NOT_IN,subquery)
		);
	}

	@Test
	public void QuerySyntaxTest()
	{
		QueryStatement query = new QueryStatement();

		query.Where()
			.And(TestTableColumns.Id.WithAlias("s"),43)
			.And(TestTableColumns.Id.WithAlias("s"),TestTableColumns.Id.WithAlias("t"));
		
		query.GroupBy(TestTableColumns.Id.WithAlias("t"));
		
		query.Select(TestTableColumns.Id.WithAlias("t"))
			.Select(new
			TransformedTableColumn("count",TestTableColumns.Id.WithAlias("s")));

		query.Execute();
	}
}
